package com.andnnl.map;

import cn.hutool.core.map.MapUtil;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap9;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Created by chenss on 2021/9/23.
 */
public class MapTest1 {
    public static void main(String[] args) {
        HashMap<String,Object> map = new HashMap<>();
        map.put("times","1");
        map.put("times1","2");

        System.out.println(map.computeIfAbsent("time3",k->"3"));


        map.entrySet().removeIf(e->e.getValue().equals("2"));
        System.out.println(map);

        if(map==null){
        }

        int times=0;
        times = MapUtil.getInt(map,"times",0);
        String timesStr = (String)map.get("times");
        System.out.println(timesStr);
        System.out.println(times);


        Map<String, Object> m = MapUtil.<String, Object>builder().putAll(map).build();
        System.out.println(m);
        String s="【深房中协】尊敬的用户，欢迎您注册综合服务系统（SISS）帐户，验证码2716，此验证码15分钟内有效。享受更多贴心服务尽在综合服务系统（SISS）！";
        System.out.println(s.length());
        System.out.println(s.getBytes().length);


        //判断删除不存在的网关
        Map<String, Object> lastRatioMap=new HashMap<>();
        lastRatioMap.put("asdf1","asdf1");
        lastRatioMap.put("asdf2","asdf2");
        lastRatioMap.put("asdf3","asdf3");
        Iterator<String> iterator = lastRatioMap.keySet().iterator();


//        logger.info("lastBean.lastRatioMap:"+JsonLib.toJson(lastBean.lastRatioMap));
        while (iterator.hasNext()) {
            String ogw = iterator.next();
            if ("asdf1".equals(ogw)) {
                iterator.remove();
//                logger.info("省网分流 key:"+newKey+", 删除不存在的gw:"+ogw);
            }
        }
//        logger.info("lastBean.lastRatioMap剔除:"+JsonLib.toJson(lastBean.lastRatioMap));

        System.out.println("lastRatioMap:"+lastRatioMap);

    }
}
